﻿using System;

namespace WolfGame {

  /// <summary>
  /// This class calls all game update logic
  /// </summary>
  class m_GameEvents {

    #region Member Variables

    private Common common;

    #endregion

    #region Constructor

    /// <summary>
    /// Instantiate the class
    /// </summary>
    /// <param name="common"></param>
    public m_GameEvents(Common common) {
      this.common = common;
    }

    #endregion

    #region Game Loop

    /// <summary>
    /// Call all of the game events to do an update.  This method is itself
    /// called by the rendering loop in v_Renderer.  As such, the speed of this
    /// game loop is completely dependent on the amount of time it takes to render
    /// the scene.  Does not work well with networking.
    /// </summary>
    public void DoGameEvents() {
      common.Keyboard.ReadKeyboard();

      // Update all of the walls
      foreach (m_RenderableSurface surface in common.Map.Surfaces)
        surface.UpdateTexture();

      // Update all of the entities
      foreach (e_EntityBase entity in common.Map.Entities)
        entity.Update();

      common.Map.UpdateVertexData();
    }

    #endregion
  }
}
